// run: $exec < input
#include <iostream>
#include <cstring>

int a[20][20];
int n, m, k;

int main()
{
	std::ios::sync_with_stdio(false);
	int T; std::cin >> T;
	while (T--) {
		std::cin >> n >> m >> k;
		std::memset(a, 0, sizeof(a));
		int r = (n - 2) * (m - 2);
		r -= k;
		int x = 0, y = 1, t = 1;
		for (int i = 0; i < r; i++) {
			a[x][y] = t;
			t += 2;
			y++;
			if (y == m - 1) {
				x++; y = 1;
			}
		}
		for (int i = 0; i < n; i++) {
			std::cout << a[i][0];
			for (int j = 1; j < m; j++) std::cout << ' ' << a[i][j];
			std::cout << '\n';
		}
	}
}

